<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title></title>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/bootstrap.css" />
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/bootstrap-responsive.css" />
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/style.css" />
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/bootstrap.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/ckform.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/common.js"></script>
    <script src="${pageContext.request.contextPath}/js/jquery.min.js?v=2.1.4"></script>
    <script src="${pageContext.request.contextPath}/js/commons_date.js"></script>

    <style type="text/css">
        body {font-size: 20px;
            padding-bottom: 40px;
            background-color:#e9e7ef;
        }
        .sidebar-nav {
            padding: 9px 0;
        }

        @media (max-width: 980px) {
            /* Enable use of floated navbar text */
            .navbar-text.pull-right {
                float: none;
                padding-left: 5px;
                padding-right: 5px;
            }
        }


    </style>
    <script>
        var econtent="";
        $(function () {
            loadData();
        });
        function loadData(currentPage,econtent) {
            $.ajax({
                url:"${pageContext.request.contextPath}/evaluate/getAllEvaluate",
                type:"post",
                data:{"currentPage":currentPage,"econtent":econtent},
                dataType:"json",
                cache:false,
                success:function (rs) {
                    $("#tbody").empty();
                    $.each(rs.records,function (index,element) {
                        var tr="<tr>\n" +
                            "\n" +
                            "                    <td>"+element.econtent+"</td>\n" +
                            "                    <td><a href=\"${pageContext.request.contextPath}/user/user_detail?uid="+element.user.uid+"\">"+element.user.uname+"</a></td>\n" +
                            "                    <td>"+element.blog.btitle+"</td>\n" +
                            "                    <td>"+get_date(element.etime)+"</td>\n" +
                            "                    <td><button type=\"button\"  id=\"deletecomment\"><a href=\"javascript:deleteEvaluate("+element.eid+")\">删除</a></button></td>\n" +
                            "\n" +
                            "            </tr>";
                        $("#tbody").append(tr);
                    })
                    $("#tfoot").empty();
                    var footTr=" <tr>\n" +
                        "            <td style=\"text-align: center\" colspan=\"5\">\n" +
                        "                <a href=\"javascript:firstPage()\">首页</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n" +
                        "                <a href=\"javascript:prePage("+rs.currentPage+")\">上一页</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n" +
                        "                <a href=\"javascript:nextPage("+rs.currentPage+","+rs.totalPage+")\">下一页</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n" +
                        "                <a href=\"javascript:lastPage("+rs.totalPage+")\">尾页</a>\n" +
                        "            </td>\n" +
                        "        </tr>";
                    $("#tfoot").append(footTr);

                }
            })
        }
        function firstPage() {
            loadData(1,econtent);

        }
        function prePage(currentPage) {
            if (currentPage-1<1){
                loadData(1,econtent);
            }else{
                loadData(currentPage-1,econtent);
            }
        }
        function nextPage(currentPage,totalPage) {
            if (currentPage+1>totalPage){
                loadData(totalPage,econtent);
            }else{
                loadData(currentPage+1,econtent);
            }

        }
        function lastPage(totalPage) {
            loadData(totalPage,econtent);
        }

        function deleteEvaluate(eid) {
            $.ajax({
                url:"${pageContext.request.contextPath}/evaluate/deleteEvaluate",
                type:"post",
                data:{"eid":eid},
                dataType:"json",
                cache:false,
                success:function (rs) {
                    if (rs.status==200){
                        alert(rs.msg);
                        loadData();
                    }else{
                        alert(rs.msg)
                    }
                }
            })

        }
        function searchEcontent() {
            loadData(1,$("#econtent").val())
        }
    </script>
</head>
<body>
<form class="form-inline definewidth m20" action="#" method="get">
     <font color="#777777"><strong>查询评价：</strong></font>
    <input type="text" name="econtent" id="econtent" class="abc input-default" placeholder="" value="">&nbsp;&nbsp;
    <a href="javascript:searchEcontent()"  class="btn btn-primary">查询评价</a>&nbsp;&nbsp;
	
</form>
<table class="table table-bordered table-hover definewidth m10">
    <thead>
    <tr>
        <th>评价内容</th>
        <th>评价人</th>
        <th>博客标题</th>
        <th>评价时间</th>
        <th>操作</th>
    </tr>
    </thead>
	    <tbody id="tbody">

        </tbody>
    <tfoot id="tfoot">


    </tfoot>
       
</table>

</body>
</html>
